Learn R Programming

gRim (version 0.1.2)

stepwise.iModel; backward; forward: Stepwise model selection in (graphical) interaction models

Description

Stepwise model selection in (graphical) interaction models

Usage

## S3 method for class 'iModel':
stepwise(object, 
 criterion = "aic", alpha = NULL, type ="decomposable",
 search="all", steps = 1000, k = 2,
 direction = "backward", fixinMAT=NULL, fixoutMAT=NULL,
 details = 0, trace = 2, ...)

backward(object,
 criterion = "aic", alpha = NULL, type = "decomposable",
 search="all", steps = 1000, k = 2,
 fixinMAT=NULL, details = 1, trace = 2,...)

forward(object,
 criterion = "aic", alpha = NULL, type = "decomposable",
 search="all", steps = 1000, k = 2,
 fixoutMAT=NULL,  details = 1, trace = 2,...)

Arguments

object
An iModel model object
criterion
Either "aic" or "test" (for significance test)
alpha
Critical value for deeming an edge to be significant/ insignificant. When criterion="aic", alpha defaults to 0; when criterion="test", alpha defaults to 0.05.
type
Type of models to search. Either "decomposable" or "unrestricted". If type="decomposable" and the initial model is decompsable, then the search is among decomposable models only.
search
Either 'all' (greedy) or 'headlong' (search edges randomly; stop when an improvement has been found).
steps
Maximum number of steps.
k
Penalty term when criterion="aic". Only k=2 gives genuine AIC.
fixinMAT
Matrix (p x 2) of edges. If those edges are in the model, they are not considered for removal.
fixoutMAT
Matrix (p x 2) of edges. If those edges are not in the model, they are not considered for addition.
direction
Direction for model search. Either "backward" or "forward".
details
Controls the level of printing on the screen.
trace
For debugging only.
...
Further arguments to be passed on to testdelete (for testInEdges) and testadd (for testOutEdges).

Value

  • An iModel model object.

See Also

cmod dmod mmod testInEdges testOutEdges

Examples

Run this code
data(reinis)
## The saturated model
m1 <- dmod(~.^., data=reinis)
m2 <- stepwise(m1)
m2

Run the code above in your browser using DataLab